package math;

public class vec2f {

    public float x;
    public float y;

    public vec2f() {
        x = 0f;
        y = 0f;
    }

    public vec2f(float x_coord, float y_coord) {
        x = x_coord;
        y = y_coord;
    }
    
    public vec2f(double x_coord, double y_coord) {
        this((float)x_coord, (float)y_coord);
    }

    public vec2f(vec2f vec) {
        this(vec.x, vec.y);
    }
    
    public void swapWith(vec2f vec) {
        vec2f vt = new vec2f(vec);
        vec.setTo(this);
        this.setTo(vt);
    }
    
    public void setTo(float vx, float vy) {
        x = vx;
        y = vy;
    }

    public void setTo(vec2f u) {
        setTo(u.x, u.y);
    }
    
    public String toString() {
        String s = "";
        s += "( " + String.format("%.3f", x) + ", " + String.format("%.3f", y) + " )";
        return s;
    }

}
